from django.db import models
# Create your models here.
from django.utils.html import format_html


class Store(models.Model):
    homeBanner_CHOICES = (
        (0, "显示首页轮播图"),
        (1, "不显示"),
    )
    store_configiratioin_ID = models.AutoField(primary_key = True)
    home_page_banner = models.ForeignKey("GoodsInfo",default="",related_name="home_page_banner_img",on_delete=models.PROTECT,verbose_name="首页轮播图1")
    home_page_banner2 = models.ForeignKey("GoodsInfo",default="",related_name="home_page_banner_img2",on_delete=models.PROTECT,verbose_name="首页轮播图2")
    home_page_banner3 = models.ForeignKey("GoodsInfo",default="",related_name="home_page_banner_img3",on_delete=models.PROTECT,verbose_name="首页轮播图3")
    home_page_banner4 = models.ForeignKey("GoodsInfo",default="",related_name="home_page_banner_img4",on_delete=models.PROTECT,verbose_name="首页轮播图4")
    announcement = models.TextField(default="[]",help_text="公告列表 先不设置")
    show_home_page_banner = models.IntegerField(choices=homeBanner_CHOICES,default=0,help_text="是否显示首页轮播图")
    # show_home_page_banner = models.BooleanField(verbose_name="已禁止",default=False,blank=True)

    show_announcement = models.IntegerField(default=0,help_text="是否显示公告")
    show_classification_icon = models.IntegerField(default=1,help_text="是否显示分类小图标")
    show_classification_banner = models.IntegerField(default=1,help_text="是否显示分类横幅")

    def __str__(self):
        return "店铺设置"

class Classification(models.Model):
    classification_ID = models.AutoField(primary_key = True)
    name = models.CharField(max_length=100,default="",help_text="分类类别名称")
    front_desc = models.TextField(default="",help_text="类别简短介绍")
    icon_url = models.CharField(max_length=500,default="[]",help_text="icon分类图标")
    img_url = models.CharField(max_length=500,default="[]",help_text="分类图片")
    img_height = models.IntegerField(default=155,help_text="图片高度")
    sort_order = models.IntegerField(default=1,help_text="排序")
    is_show = models.IntegerField(default=1,help_text="是否启用")

    def __str__(self):
        return self.name

class Commodity_specification(models.Model):
    Commodity_specification_ID = models.AutoField(primary_key = True)
    goods_sn = models.IntegerField(help_text="商品sku")
    goods_name = models.CharField(max_length=100,help_text="快递单上面的简称")
    specification = models.CharField(max_length=50,help_text="型号/规格")
    goods_weight = models.CharField(max_length=100,help_text="重量")
    cost_price = models.IntegerField(help_text="成本 ( 元 )")
    retail_price = models.IntegerField(help_text="零售价 ( 元 )")
    goods_number = models.IntegerField(help_text="库存")


class GoodsInfo(models.Model):
    GoodsInfo_ID = models.AutoField(primary_key = True)
    category_ID = models.ForeignKey("Classification",default=0,on_delete=models.PROTECT,verbose_name="商品分类")
    pic_url = models.CharField(max_length=100,default="",verbose_name="首页广告轮播图展示的图片")
    gallery = models.TextField(default="[]",verbose_name="商品轮播图")
    name = models.CharField(max_length=100,default="",verbose_name="商品名称")
    goods_brief = models.TextField(verbose_name="商品简介")
    goods_unit = models.CharField(verbose_name="商品单位",max_length=10,default="",help_text="( 如 件 , 包 , 带 )")
    sell_volume = models.IntegerField(verbose_name="销量")
    goods_number = models.IntegerField(default=0,verbose_name="库存")
    retail_price = models.IntegerField(default=100,verbose_name="售价")
    goods_desc = models.TextField(verbose_name="商品详情",default="[]",help_text="商品详情图片url")
    specification = models.TextField("商品规格",default="[]",help_text="名称  ,  不同规格")

    def __str__(self):
        return self.name + "    分类:   " + self.category_ID.name




















